#include "Employee.h"
#include "Utility.h"

int main()
{
	CEmployee *pEmployee = NULL;
	Node *pNode;
	bool bFlag = true;
	int wChoice;
	List m_list;
	CreateList(&m_list);
	do
	{
		//Show menu
		Menu();
		// Input a chose
		printf("\nInput your chose: ");
		scanf("%d", &wChoice);
		switch (wChoice)
		{
		case 1:
			pEmployee->AutoInputEmployee(&m_list);
			End();
			break;
		case 2:
			// Input student
			char chPress;
			do
			{
				pEmployee = new CEmployee();
				printf("Input Student info:\n");
				pEmployee->InputEmployee(pEmployee);
				pNode = CreateNode(pEmployee);
				AddHead(&m_list, pNode);
				End();
				printf("Do you want to continues ? (Y/N) ");
				fflush(stdin);
				chPress = getchar();
				End();
			}while(chPress != 'n' && chPress != 'N');
			
			break;
		case 3:
			// Sort student belong to birthday
			WriteToFile(&m_list);
			End();
			break;
		case 4:
			// Sort student belong to birthday
			pEmployee->QuickSortBirthday(&m_list);
			pEmployee->OutputEmployee(&m_list);
			End();
			break;
		case 5:
			// Sort student belong to salary
			pEmployee->QuickSortSalary(&m_list);
			pEmployee->OutputEmployee(&m_list);
			End();
			break;
		case 6:
			pEmployee->RemoveEmployee(&m_list);
			pEmployee->OutputEmployee(&m_list);
			End();
			break;
		case 7:
			// Display list student
			pEmployee->OutputEmployee(&m_list);
			End();
			break;
		case 0:
			//Quit program
			bFlag = false;			
			break;
		default:
			// exception case
			printf("Please enter another chose\n");
			getch();
			system("cls");
			break;
		}
	}while (bFlag);
	return 0;
}

